package com.tckdq.tcc.uploadvideo;

import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.io.InputStream;

public class UpLoadvVideo {
    /**
     * 本地文件上传接口
     *
     * @param accessKeyId
     * @param accessKeySecret
     * @param title
     * @param fileName
     */
   /* private static void testUploadVideo(String accessKeyId, String accessKeySecret, String title, String fileName) {
        UploadVideoRequest request = new UploadVideoRequest(accessKeyId, accessKeySecret, title, fileName);
        *//* 可指定分片上传时每个分片的大小，默认为2M字节 *//*
        request.setPartSize(2 * 1024 * 1024L);
        *//* 可指定分片上传时的并发线程数，默认为1，(注：该配置会占用服务器CPU资源，需根据服务器情况指定）*//*
        request.setTaskNum(1);

        UploadVideoImpl uploader = new UploadVideoImpl();
        UploadVideoResponse response = uploader.uploadVideo(request);
        System.out.print("RequestId=" + response.getRequestId() + "\n");  //请求视频点播服务的请求ID
        if (response.isSuccess()) {
            System.out.print("VideoId=" + response.getVideoId() + "\n");
        } else {
            *//* 如果设置回调URL无效，不影响视频上传，可以返回VideoId同时会返回错误码。其他情况上传失败时，VideoId为空，此时需要根据返回错误码分析具体错误原因 *//*
            System.out.print("VideoId=" + response.getVideoId() + "\n");
            System.out.print("ErrorCode=" + response.getCode() + "\n");
            System.out.print("ErrorMessage=" + response.getMessage() + "\n");
        }
    }
    public static void main(String[] args) {
        // 一、视频文件上传
        // 视频标题(必选)
        String title = "测试标题";
        String fileName = "C:\\Users\\Lenovo\\Desktop\\谷粒学院学习\\guli_parent-master\\Doc\\1-阿里云上传测试视频\\6 - What If I Want to Move Faster.mp4";
        System.out.println("LTAI5tHSsVqmHXCYmYCvZcAN" + "     " + "accessKeySecret");
        // 本地文件上传
        testUploadVideo("LTAI5tHSsVqmHXCYmYCvZcAN", "T7GKd5Hly8rTeRGeZBq8lIcAIKzYZT", title, fileName);
    }
    *//*上传视频流*//*
    public String upload(MultipartFile file) throws IOException {
        //获取名字
        String originalFilename = file.getOriginalFilename();
        String title = originalFilename.substring(0, originalFilename.lastIndexOf("."));

        String videoId =null;

        //获取文件的输入流

        InputStream inputStream = file.getInputStream();
        UploadStreamRequest request = new UploadStreamRequest(ConstVodProperties.ACCESSKEYID, ConstVodProperties.ACCESSKEYSCRET, title, originalFilename, inputStream);
        UploadVideoImpl uploadVideo = new UploadVideoImpl();
        UploadStreamResponse response = uploadVideo.uploadStream(request);
        videoId = response.getVideoId();
        return videoId;
    }
*/
}
